﻿using Microsoft.Xna.Framework;

namespace PoolGame2.Physics
{
    public class Cushion : PhysicsObject
    {

        public Vector3 mainStart;
        public Vector3 mainEnd;
        public Vector3 start;
        public Vector3 end;
        
        public Vector3 startNormal;
        public Vector3 mainNormal;
        public Vector3 endNormal;

        public bool inCollision = false;
        
        public Cushion(Vector3 start, Vector3 mainStart, Vector3 mainEnd, Vector3 end)
        {
            this.mainStart = mainStart;
            this.mainEnd = mainEnd;
            this.start = start;
            this.end = end;
            CalculateNormals();
        }
        
        private void CalculateNormals()
        {
            startNormal = mainStart - start;
            startNormal = Vector3.Cross(startNormal, Vector3.Up);
            startNormal.Normalize();

            mainNormal = mainEnd - mainStart;
            mainNormal = Vector3.Cross(mainNormal, Vector3.Up);
            mainNormal.Normalize();

            endNormal = end - mainEnd;
            endNormal = Vector3.Cross(endNormal, Vector3.Up);
            endNormal.Normalize();
        }
    }
}
